package cn.community.system.service.impl;

import cn.community.system.mapper.AssociationReportMapper;
import cn.community.system.query.AssociationDeviceLendReportQuery;
import cn.community.system.query.AssociationDeviceReturnReportQuery;
import cn.community.system.query.AssociationReportQuery;
import cn.community.system.service.IAssociationReportService;
import cn.community.system.util.UserContext;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AsssociationReportServiceImpl implements IAssociationReportService{

    @Autowired
    private AssociationReportMapper associationReportMapper;

    @Override
    public PageInfo selectAllActivityReport(AssociationReportQuery qo) {
        Long id = UserContext.getCurrentAssociation().getId();
        qo.setSponId(id);
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Map> list = associationReportMapper.selectAllActivityReport(qo);
        return new PageInfo(list);
    }

    @Override
    public List<Map> listAll(AssociationReportQuery qo) {
        Long id = UserContext.getCurrentAssociation().getId();
        qo.setSponId(id);
        return associationReportMapper.selectAllActivityReport(qo);
    }

    @Override
    public PageInfo selectAllDeviceReport(AssociationDeviceLendReportQuery qo) {
        Long id = UserContext.getCurrentAssociation().getId();
        qo.setSponId(id);
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Map> list = associationReportMapper.selectAllDeviceReport(qo);
        return new PageInfo(list);
    }

    @Override
    public List<Map> listAllDevice(AssociationDeviceLendReportQuery qo) {
        Long id = UserContext.getCurrentAssociation().getId();
        qo.setSponId(id);
        return associationReportMapper.selectAllDeviceReport(qo);
    }

    @Override
    public PageInfo selectReturnDeviceReport(AssociationDeviceReturnReportQuery qo) {
        Long id = UserContext.getCurrentAssociation().getId();
        qo.setSponId(id);
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Map> list = associationReportMapper.selectReturnDeviceReport(qo);
        return new PageInfo(list);
    }

    @Override
    public List<Map> listReturnDevice(AssociationDeviceReturnReportQuery qo) {
        Long id = UserContext.getCurrentAssociation().getId();
        qo.setSponId(id);
        return associationReportMapper.selectReturnDeviceReport(qo);
    }
}
